<?
function getDirTree($dir, $p=true)
{
 $d = dir($dir);
 $x = array();
 $key = 0;
 
 while (false !== ($r = $d->read()))
 {
  if($r == "." || $r == "..")
   continue;

  $current = "$dir/$r";
  if(is_dir($current))
  {
   $x[$key] = $current;
   $key+= 1;
   foreach(getDirTree($current, $p) as $value)
   {
    $x[$key] = $value;
    $key += 1;
   }
  } else if($p)
  {
   $x[$key] = $current;
   $key+= 1;
  }
 }
 return $x;
}


?>